<?php

/*

  Action	$4

  Trash this card. Gain a card costing up to $5.

 */

class Feast extends Card implements iAction, iKingdom, iBasic {

    private $gainedCard;

    public function __construct() {
        parent::__construct("Feast", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Trash this card. Gain a card costing up to $5.");
    }

    public function play(Game $game, $isRealCard) {


        $five_or_less_cards = $game->getBoardCardsByPrice(new Price(), new Price(5));
        $output = MySocket::GetUserReply($game, Input_ChooseOne, $five_or_less_cards, 1, 1, null, "Choose a card");

        $card_name = $output[0];
        $game->moveCardFromPileToPile($this, PlayArea, Trash);
        $card = $game->moveCardFromPileToPile($card_name, BoardCards, DiscardPile);
        $this->gainedCard = $card;
        ScreenDisplay::addScreenMessage($game, true, "trash " . nicePrint($this) . " and gain  " . nicePrint($card), "trashes " . nicePrint($this) . " and gains " . nicePrint($card));

        $game->cardActionFinished();
        return true;
    }

    public function undoParamsPlay($undoParams) {
        $undoParams['actionPile'] = Trash;
        $undoParams['gainedCard'] = $this->gainedCard;
        return array($this->undoPlay, $undoParams);
    }

    public function undo(Game $game, $undoParams) {
        $game->undo_func_moveCardFromPileToPile($undoParams['gainedCard'], DiscardPile, BoardCards);
        $game->undo_func_moveCardFromPileToPile($this, Trash, PlayHand);
    }
}

?>